def is_valid_ sequence (sequence) :
stack = []
brackets = {'(: 9', '1: "1', "': '', '': '>'}
for char in sequence:
if char in brackets. keys ():
stack. append (char)
elif char in brackets. values ():
if not stack or brackets [stack-pop()] != char:
return False
return not stack
sequence = input ( )
print (is_valid_sequence(sequence) )